<script id="switchTemplate" type="text/template">
    <form id="switchForm" class="layui-form" action="">
        项目
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">项目</label>
            <div class="layui-input-block">
                <select name="projectId" lay-verify="required" lay-filter="projectIdFilter" >
                    {{# let branchList = [] }}
                    {{# $.each(d.projectList,(i,p)=>{ }}
                    <option value="{{p.id}}" {{# if(p.id== d.projectId){ }}selected{{# branchList = p.branchList; } }}>
                        {{p.name}}
                    </option>
                    {{# }) }}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分支</label>
            <div class="layui-input-block">
                <select name="branchId" lay-verify="required">
                    {{# $.each(branchList,(i,b)=>{ }}
                    <option value="{{b.id}}" {{# if(b.id == d.branchId){ }}selected{{# } }}>{{b.name}}</option>
                    {{# }) }}
                </select>
            </div>
        </div>
        全局环境
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <select name="envId" lay-verify="required" lay-filter="envIdFilter">
                    {{# $.each(d.envList,(i,v)=>{ }}
                    <option value="{{v.id}}" {{# if(v.id== d.envId){ }}selected{{# } }}>{{v.name}}</option>
                    {{# }) }}
                </select>
            </div>
        </div>

        {{# $.each(d.envList,(i,e)=>{ }}
        <div class="env-div env-id-{{e.id}} {{# if(e.id != d.envId){ }}layui-hide{{# } }}">
            <div class="layui-form-item">
                <label class="layui-form-label">域名</label>
                <div class="layui-input-block">
                    <input type="text" name="domain" readonly value="{{e.domain}}" required
                           lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            {{# $.each(e.headerMap,(i,h)=>{ }}
            <div class="layui-form-item">
                <label class="layui-form-label">{{h.key}}</label>
                <div class="layui-input-block">
                    <input type="text" name="{{h.key}}" key="env-{{ e.id+'-'+h.key }}" value="{{h.value}}" required
                           lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            {{# }); }}
        </div>
        {{# }) }}
    </form>
</script>